package com.letere.bean;

import lombok.Data;

/**
 * @author letere
 * @create 2021-02-04 17:16
 */
@Data
public class Result {
    //状态码
    private Integer code;
    //返回信息
    private String message;
    //数据
    private Object data;

    private Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    //结果封装
    public static Result result(Integer code, String message, Object data) {
        return new Result(code, message, data);
    }

    //成功
    public static Result success(Object data) {
        return result(200, null, data);
    }

    //失败
    public static Result failure(String message) {
        return result(400, message, null);
    }
}
